<!doctype html>
<html lang="en">
	<head>
		<script>
			var extension = window.opera.extension;
			window.addEventListener("load", function() {
				var UIItemProperties = {
					disabled: true,
					title: "Vanishing Click",
					icon: "icons/icon_18x18.png",
					onclick: function(){
						var tab = opera.extension.tabs.getFocused();
						if (tab) {
							tab.postMessage('vanishing-click');
							//button.disabled = true;
						}
					}
				}
				var button = opera.contexts.toolbar.createItem(UIItemProperties);
				opera.contexts.toolbar.addItem(button);

				function enableButton() {
					var tab = opera.extension.tabs.getFocused();
					if (tab) {
						button.disabled = false;
					} else {
						button.disabled = true;
					}
				}

				// Enable the button when a tab is ready.
				opera.extension.onconnect = enableButton;
				opera.extension.tabs.onfocus = enableButton;
				opera.extension.tabs.onblur = enableButton;

			}, false);
		</script>
	</head>
	<body>
	</body>
</html>